package com.retail.statistics.controller;

import com.retail.core.entity.result.Result;
import com.retail.global.security.LoginUser;
import com.retail.global.security.LoginUserUtil;
import com.retail.statistics.client.DashboardStatisticsClient;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 订单信息 API
 *
 * @author Administrator
 */
@Api(tags = "数据统计 API")
@RestController
@RequestMapping("/dashboard")
public class DashboardStatisticsController {

    @Autowired
    private DashboardStatisticsClient dashboardStatisticsClient;

    /**
     * 数据统计
     * @return
     */
    @GetMapping("fullStatistics")
    public Result fullStatistics() {
        LoginUser loginUser = LoginUserUtil.getPrincipal();
        return dashboardStatisticsClient.fullStatistics(loginUser.getId(), loginUser.getUserType());
    }

    /**
     * 数据统计
     * @param dateType  订单类别
     * @return
     */
    @GetMapping("orderFullStatistics/{dateType}")
    public Result orderFullStatistics(@PathVariable("dateType") String dateType) {
        LoginUser loginUser = LoginUserUtil.getPrincipal();
        return dashboardStatisticsClient.orderFullStatistics(loginUser.getId(), loginUser.getUserType(),dateType);
    }

    /**
     * 数据统计
     * @param dateType  订单类别
     * @return
     */
    @GetMapping("ordershopListFullStatistics/{dateType}")
    public Result ordershopListFullStatistics(@PathVariable("dateType") String dateType) {
        LoginUser loginUser = LoginUserUtil.getPrincipal();
        return dashboardStatisticsClient.ordershopListFullStatistics(loginUser.getId(), loginUser.getUserType(),dateType);
    }

    /**
     * 商户订单数统计
     * @return
     */
    @GetMapping("orderShopStatistics/{dateType}")
    public Result orderShopStatistics(@PathVariable("dateType") String dateType) {
        LoginUser loginUser = LoginUserUtil.getPrincipal();
        return dashboardStatisticsClient.orderShopStatistics(loginUser.getId(), loginUser.getUserType(),dateType);
    }
}
